package com.example.demo.util;

import com.alibaba.druid.support.logging.LogFactory;
import com.example.demo.controller.TransferController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

@Component
@Configurable

@EnableScheduling      //打开quartz定时器总开关
public class TimeTimer {

    private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(TransferController.class);
    //每5分钟执行一次  判断清除过期数据
//    @Scheduled(cron = "0 0/5 *  * * * ")
    public void reportCurrentByCron(){
        LOG.info ("Scheduling Tasks Examples By Cron: The time is now " + dateFormat ().format (new Date()));
        //每5分钟执行一次，清除过期数据
    }
    private SimpleDateFormat dateFormat(){
        return new SimpleDateFormat ("HH:mm:ss");
    }
}